{% extends 'bookmanage/base.html' %}

{% block content %}
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">修改图书</div>
        <div class="col-md-5">
            <div class="panel-body">
                <form action="{% url 'book_change' id=book_list.id %}" method="post">
                    <div class="form-group">
                        书名: <input type="text" class="form-control" name="name" value="{{ book_list.name }}">
                    </div>
                    <div class="form-group">
                        价格: <input type="text" class="form-control" name="price" value="{{ book_list.price }}">
                    </div>
                    <div class="form-group">
                        上架时间: <input type="date" class="form-control" name="create_time"
                                     value="{{ book_list.create_time|date:"Y-m-d" }}">
                    </div>
                    <div class="form-group">
                        作者：<select name="auther" class="form-control" multiple>
                        {% for auther in auther_list %}
                            {% if auther in book_list.auther.all %}
                                <option value="{{ auther.id }}" selected>{{ auther.name }}</option>
                            {% else %}
                                <option value="{{ auther.id }}">{{ auther.name }}</option>
                            {% endif %}

                        {% endfor %}
                    </select>
                    </div>
                    <div class="form-group">
                        出版社：<select name="publish" class="form-control">
                        {% for publish in publish_list %}
                            {% if book_list.publish.id == publish.id %}
                                <option value="{{ publish.id }}" selected>{{ publish.name }}</option>
                            {% else %}
                                <option value="{{ publish.id }}">{{ publish.name }}</option>
                            {% endif %}

                        {% endfor %}
                    </select>
                    </div>
                    <input type="submit" class="form-control" value="提交">

                </form>
            </div>
        </div>
    </div>

{% endblock %}